#include <bits/stdc++.h>
using namespace std;
int a[10];
signed main() {
  for (int i = 1; i <= 5; i++)
    cin >> a[i];
    
  for (int i = 2; i <= 5; i++) {
    // 枚举所有相邻的两位
    swap(a[i - 1], a[i]);
    int ok = 1;
    for (int j = 1; j <= 5; j++) {
      if (a[j] != j)
        ok = 0;
    }
    if (ok == 1) {
      cout << "Yes" << endl;
      return 0;
    }
    swap(a[i - 1], a[i]);
  }
  cout << "No" << endl;

  return 0;
}